<template>
  <div>
    <x-header :left-options="{backText: ''}" :title="$route.name"></x-header>
    <div class="gz-content">
      <div class="screen-box">
        <div class="search-input">
          <group style="margin: 0;">
            <x-input title="title" v-model="value" placeholder="请输入姓名、手机号、证件号进行查询">
              <template slot="label">
                <div style="display: flex;align-items: center;justify-content: center;">
                  <x-icon type="ios-search-strong" size="20" style="margin-right: 10px;color: #979797"></x-icon>
                </div>
              </template>
            </x-input>
          </group>
        </div>
        <div class="screen-icon" @click="showModal = true">
          <!-- <img :src="require('@/assets/screen.svg')" style="width: inherit;" /> -->
        </div>
      </div>
      <!-- List -->
      <div class="list-box">
        <scroller ref="myscroll" :on-refresh="refresh" :on-infinite="infinite" :no-data-text="'暂无更多'"
          class="scroll-view" :height="scrollHeight">
          <div v-for="(task,tindex) in taskList" :key="tindex">
            <gz-list-card :content="task" @click="taskDispose"></gz-list-card>
          </div>
        </scroller>
      </div>
    </div>
    <screen-modals v-model="showModal"></screen-modals>
  </div>
</template>

<script>
  import Vue from 'vue'
  import {
    gzListCard,
    gzModal
  } from '@/components/customize'
  import publicFun from './publicFun'
  import VueScroller from "vue-scroller";
  import screenModals from './screenModals.vue'
  import { Dialog } from 'vant';

  Vue.use(VueScroller);
  export default {
    components: {
      gzListCard,
      gzModal,
      screenModals
    },
    data() {
      return {
        value: '',
        showModal: false,
        searchParam: {
          "just_look_self": true,
          "eme.key_$VEQ": '',
          "statusList": 1
        },
      }
    },
    mixins: [publicFun],
    mounted() {
      this.$refs.myscroll.finishInfinite(true);
      let searchParam = this.searchParam
      this.pageParams = {
        searchParam: searchParam,
        type: 'taskCharge'
      }
      this.getTaskList({
        searchParam: searchParam,
        type: 'taskCharge'
      })
    },
    methods: {
      taskDispose(fun,row) {
        let message = ''
        let url = '/taskPool/update'
        let data = {
          id: row.id,
          version: row.version
        }
        let resultMsg = ''
        let errMsg = ''
        if(fun == 'qianshou') {
          message = '是否确认签收该任务'
          data.status = 2
          resultMsg = '签收成功'
          errMsg = '签收失败'
        }else if(fun == 'jujue') {
          message = '是否确认拒绝该任务'
          data.status = 0
          resultMsg = '拒绝成功'
          errMsg = '拒绝失败'
        }
        Dialog.confirm({
          title: '提示信息',
          message: message
        }).then(() => {
          this.$toast.loading({
            message: '加载中...',
            duration: 0
          })
          let post = this.baseService.post(this.__ctx + url, data)
          post.then((res) => {
            if(res.isOk) {
              this.$toast.success(resultMsg)
              let that = this
              setTimeout(() => {
                that.refresh()
              },2000)
            }else {
              this.$toast.fail(res.msg)
            }
          }).catch(err => {
            this.$toast.fail(errMsg)
          })
        })
      }
    }
  }
</script>

<style lang="less" scoped>
  @import "./publicStyle.less";
</style>
